import PageConst from './PageConst';


export default {

  defaults(props) {
    return {
      ...PageConst,
      steps: [],
    }
  },


  async timeline(ctx, data){
    const content = await
      ctx.fn.DB.emp.info.timeline({Authorization: ctx.getProps().token, ...data}).catch(
        (error) => {
          console.log(error);
        }
      );

    if (content) {
      ctx.setState(
        React.addons.update(ctx.getState(), {
          steps: {
            $set: content
          },
        }));
    }
  },

  async jbxx(ctx, data){
    const content = await ctx.fn.DB.emp.info.jbxx({Authorization: ctx.getProps().token, ...data}).catch(
      (error) => {
        console.log(error);
      }
    );

    if (content) {
      ctx.setState(
        React.addons.update(ctx.getState(), {
          emp: {$set: content},
        })
      );
    }
  },

  async zsxx(ctx, data){
    const content = await ctx.fn.DB.emp.info.zsxx({Authorization: ctx.getProps().token, ...data}).catch(
      (error) => {
        console.log(error);
      }
    );

    if (content) {
      ctx.setState(
        React.addons.update(ctx.getState(), {
          zsxxProps: {
            jsxdata: {
              data: {$set: content}
            }
          }
        })
      );
    }
  },

  async zjxmxx(ctx, data){
    const content = await ctx.fn.DB.emp.info.zjxmxx({Authorization: ctx.getProps().token, ...data}).catch(
      (error) => {
        console.log(error);
      }
    );

    if (content) {
      ctx.setState(
        React.addons.update(ctx.getState(), {
          zjxmProps: {
            jsxdata: {
              data: {$set: content}
            }
          }
        })
      );
    }
  },
  async yjxmxx(ctx, data){
    const content = await ctx.fn.DB.emp.info.yjxmxx({Authorization: ctx.getProps().token, ...data}).catch(
      (error) => {
        console.log(error);
      }
    );

    if (content) {
      ctx.setState(
        React.addons.update(ctx.getState(), {
          yjxmProps: {
            jsxdata: {
              data: {$set: content}
            }
          }
        })
      );
    }
  },
}
